- Chapter 4: Writing classes

Driver class ---> client program: Main.java
Service provider class ---> Helper class: Die.java

- Default constructor
- Instance variable vs local variable (Scope)
- Visibility modifiers (public, private, protected)
- Formal parameter vs actual parameter
- Called method vs calling methods

- Default constructor: 
If you don't provide your own constructor ===> A default constructor is created
public Die() {

}

- Instance variables vs local variables (scope)
Scope: the location where declare the variable ---> defines the scope of the variable
the area in the code where we are allowed to use variable

faceValue (instance variable): scope = the entire class ==> it can be used anywhere inside it
value (local variable): bound to a specific method ==> scope is restricted to the body of the method

Lifecyle of these variables: When does Java create faceValue? When does Java create value?

Die die1 = new Die(); // faceValue = 6
Every time an object is created, a new copy of the faceValue variable is created. 
Die die2 = new Die(); // faceValue = 6

When does Java create value?

die1.setFaceValue(6); // value = 6
The value variable is create the instant we use/call/invoke the method. It ceases to exist
before we exit the body of the method. 

When does Java destroy faceValue?

It gets destroyed before exiting the main method

- Visibility modifier:
public, private

attributes

private
Encapsulation: encapsulating sensitive information within the class



methods

public

getter method (getFaceValue)===> provides you with the ability to access a private member of the 
class ===> accessor method

setter method (setFaceValue) ===> It enables to change the value of a private member of the class
===> Mutator method

- Formal parameter vs actual parameters

Formal parameter: the parameter used when creating the method
public void setFaceValue(int value)

Actual parameter: die1.setFaceValue(6); // actual parameter

- Calling vs called method
Main.java
main {

	die1.roll();
}

main is calling roll ==> main: calling method and roll: called method
If the calling method and the called method are defined in two different classes =>
you use the called method through an object

Die.java
roll {
	generateRndValue()
}

roll is calling generateRndValue ===> roll: calling method and generateRndValue: called method

If the calling and called methods are defined inside the same class => only the name of the 
called method is needed. 




















 